package com.xszx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xszx.entity.TMeneu;
import com.xszx.entity.TRoel;
import com.xszx.mapper.RoleMenuMapper;
import com.xszx.mapper.TMeneuMapper;
import com.xszx.mapper.TRecordMapper;
import com.xszx.service.TRoelService;
import com.xszx.mapper.TRoelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 34129
* @description 针对表【t_roel】的数据库操作Service实现
* @createDate 2024-01-08 20:40:47
*/
@Service
public class TRoelServiceImpl extends ServiceImpl<TRoelMapper, TRoel>
    implements TRoelService{

    @Autowired
    private TRoelMapper roelMapper;

    @Autowired
    private RoleMenuMapper roleMenuMapper;

    /**
     * 遍历所有角色信息
     * @return
     */
    @Override
    public List<TRoel> selectRoelList() {
        return roelMapper.selectRoelList();
    }

    /**
     * 根据账号查询对应的权限
     * @param account
     * @return
     */
    @Override
    public TRoel getRoelNameByAccount(String account) {
        return roelMapper.getRoelNameByAccount(account);
    }

    /**
     * 添加角色
     * @param roel
     * @return
     */
    @Override
    public boolean insertRoel(TRoel roel) {
        return roelMapper.insertRoel(roel);
    }

    /**
     * 修改角色信息
     * @param roel
     * @return
     */
    @Override
    public boolean updateRoel(TRoel roel) {

        int i = roelMapper.updateById(roel);
        if(i>0){
            return true;
        }

        return false;
    }

    /**
     * 删除角色
     * @param rid
     * @return
     */
    @Override
    public int deleteRoel(long rid) {

        int i = roelMapper.deleteById(rid);
        //删除中间表数据
        roleMenuMapper.deleteByRid(rid);
        return i;
    }

    @Override
    public TRoel getRolebyId(TRoel tRoel) {
        return roelMapper.getRolebyId(tRoel);
    }

}




